//
//  ThreeTableViewCell.m
//  CarHome
//
//  Created by 蒋寒霄 on 14-9-19.
//  Copyright (c) 2014年 WJN_work@163.com. All rights reserved.
//

#import "ThreeTableViewCell.h"
//ThirdParty
#import "UIImageView+WebCache.h"

@implementation ThreeTableViewCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
        [self createCellView];
    }
    return self;
}

#pragma mark -
#pragma createCellView
- (void)createCellView
{
    //标题
    _titleLabel_rec = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, self.frame.size.width - 20, 20)];
    _timeLabel_rec.font = [UIFont boldSystemFontOfSize:18];
    _timeLabel_rec.textColor = [UIColor blackColor];
    [self.contentView addSubview:_titleLabel_rec];
    [_titleLabel_rec release];
    //时间
    _timeLabel_rec = [[UILabel alloc] initWithFrame:CGRectMake(_titleLabel_rec.frame.origin.x, _titleLabel_rec.frame.origin.y + _titleLabel_rec.frame.size.height + 3, 100, 14)];
    _timeLabel_rec.font = [UIFont systemFontOfSize:12];
    _timeLabel_rec.textColor = myColor_dark;
    [self.contentView addSubview:_timeLabel_rec];
    [_timeLabel_rec release];
    //左图片
    _imageLeft_rec = [[UIImageView alloc] initWithFrame:CGRectMake(_timeLabel_rec.frame.origin.x, _timeLabel_rec.frame.origin.y + _timeLabel_rec.frame.size.height + 3, 96, 72)];
    _imageLeft_rec.backgroundColor = [UIColor cyanColor];
    [self.contentView addSubview:_imageLeft_rec];
    [_imageLeft_rec release];
    //居中图片
    _imageCenter_rec = [[UIImageView alloc] initWithFrame:CGRectMake(_imageLeft_rec.frame.origin.x + _imageLeft_rec.frame.size.width + 6, _imageLeft_rec.frame.origin.y, 96, 72)];
    _imageCenter_rec.backgroundColor = [UIColor cyanColor];
    [self.contentView addSubview:_imageCenter_rec];
    [_imageCenter_rec release];
    //右图片
    _imageRight_rec = [[UIImageView alloc] initWithFrame:CGRectMake(_imageCenter_rec.frame.origin.x + _imageCenter_rec.frame.size.width + 6, _imageCenter_rec.frame.origin.y, 96, 72)];
    _imageRight_rec.backgroundColor = [UIColor cyanColor];
    [self.contentView addSubview:_imageRight_rec];
    [_imageRight_rec release];
}

#pragma mark 方法传值
- (void)setData:(FoucusImageModel *)model
{
    _titleLabel_rec.text = model.image_title;
    _timeLabel_rec.text = model.image_time;
    //查找http
    NSRange subStr = [model.image_indexDetail rangeOfString:@"http"];
    if (subStr.location != NSNotFound) { //找到第一个http
        NSString *threeUrl = [model.image_indexDetail substringFromIndex:subStr.location];//截取之后部分
        NSArray *arrDetail = [threeUrl componentsSeparatedByString:@","];//分割字符串为数组
        [_imageLeft_rec sd_setImageWithURL:[NSURL URLWithString:[arrDetail objectAtIndex:0]] placeholderImage:[UIImage imageNamed:@"Loading.png"]];
        [_imageCenter_rec sd_setImageWithURL:[NSURL URLWithString:[arrDetail objectAtIndex:1]] placeholderImage:[UIImage imageNamed:@"Loading.png"]];
        [_imageRight_rec sd_setImageWithURL:[NSURL URLWithString:[arrDetail objectAtIndex:2]] placeholderImage:[UIImage imageNamed:@"Loading.png"]];
    }
    
}

- (void)awakeFromNib
{
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
